<template>

 <div class="box">
     <el-form   class="from">
       <h3>系统登录</h3>
       <el-form-item  >
         <el-input v-model="emp.ename" placeholder="账号" />
       </el-form-item>
       <el-form-item >
         <el-input show-password v-model="emp.pwd" placeholder="密码"/>
       </el-form-item>
       <el-form-item>
         <el-button class="button" type="primary" @click="login">登录</el-button>
       </el-form-item>
     </el-form>
 </div>
</template>

<script >
import { ElMessage } from 'element-plus'
export default {
  name: "login",
  data(){
    return{
      emp:{ename:'',pwd:''},
      emplist:[]
    }
  },
  methods:{
    login(){
      this.$axios.get("http://localhost:8080/emp/login?ename="+this.emp.ename+"&pwd="+
          this.emp.pwd).then((res)=>{
            this.emplist=res.data
        sessionStorage.setItem("emp",JSON.stringify(this.emplist))
        console.log(res.data)
        if (res.data!=""&&res.data!=null){
          delete res.data.password
          this.$router.push("/home")
          this.$store.commit("emp",res.data)
        }else {
             ElMessage.error("登陆失败")
        }
    })
  }
}
}

</script>

<style scoped>
   .box{
     width: 400px;
     height: 300px;
     border: solid 1px lightgreen;
     margin: 0px auto;
     border-radius: 10px;
     box-shadow: 0px 0px 10px 10px lightgreen;

   }
   .from{
     text-align: center;
     width: 70%;
     margin: 10px auto;

   }
   .button{
     width: 100%;
   }

</style>